import 'package:flutter/material.dart';
import 'package:kuaitong/pages/homePage.dart';
import 'package:kuaitong/pages/address.dart';
import 'package:kuaitong/pages/my.dart';

class Index extends StatefulWidget {
  @override
  _RootPageState createState() => _RootPageState();
}

class _RootPageState extends State<Index> {
  //界面数组
  List<Widget> pages = [
    HomePage(),
    Address(),
    My()
  ];
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        bottomNavigationBar: BottomNavigationBar(
            onTap: (int index){
              _currentIndex = index;
              setState(() {});
            },
            selectedFontSize: 12.0,  //设置选中的字体大小
            type: BottomNavigationBarType.fixed,
            fixedColor: Color(0xffee6728),
            currentIndex: _currentIndex,
            items: <BottomNavigationBarItem>[
              BottomNavigationBarItem(
                  icon: Image(height: 20,width: 20, image: AssetImage('assets/home.png')), //未选中时的图标
                  activeIcon: Image(height: 20,width: 20, image: AssetImage('assets/home-g.png')),  //选中时的图标
                  // ignore: deprecated_member_use
                  title: Text('首页')
              ),
              BottomNavigationBarItem(
                  icon: Image(height: 20,width: 20, image: AssetImage('assets/address.png')),
                  activeIcon: Image(height: 20,width: 20, image: AssetImage('assets/address-g.png')),
                  title: Text('地址')
              ),
              BottomNavigationBarItem(
                  icon: Image(height: 20,width: 20, image: AssetImage('assets/my.png')),
                  activeIcon: Image(height: 20,width: 20, image: AssetImage('assets/my-g.png')),
                  title: Text('我的')
              ),
            ]
        ),
        body: pages[_currentIndex],
      ),
    );
  }
}